package com.rico.deploy.service.impl;

import com.github.pagehelper.PageHelper;
import com.rico.deploy.entity.Academic;
import com.rico.deploy.mapper.AcademicMapper;
import com.rico.deploy.service.AcademicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author 吴泽胜
 * @FileName AcademicServiceImpl
 * @date 2021-04-23 4:33 下午
 * @Software: IntelliJ IDEA
 */
@Service
public class AcademicServiceImpl implements AcademicService {

    @Autowired
    private AcademicMapper academicMapper;

    @Override
    public List<Academic> selectAll(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        return academicMapper.selectAll();
    }

    @Override
    public List<Academic> selectBycampusName(String campusName) {
        Example example = new Example(Academic.class);
        example.createCriteria().andEqualTo("campus_name",campusName);
        return academicMapper.selectByExample(example);
    }


    @Override
    public List<Academic> selectAll() {
        return academicMapper.selectAll();
    }

    @Override
    public Academic selectById(Integer id) {
        return academicMapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertAcademic(Academic academic) {
        return academicMapper.insert(academic);
    }

    @Override
    public int deleteAcademicById(Integer id) {
        return academicMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateAcademic(Academic academic) {
        return academicMapper.updateByPrimaryKey(academic);
    }
}
